/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PriceViewDialog.java
 *
 * Created on Aug 18, 2009, 9:26:37 AM
 */
package org.plotnikov.pricemaker;

import java.io.IOException;
import java.io.StringReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.text.BadLocationException;
import javax.swing.text.html.HTML;
import javax.swing.text.html.HTML.Tag;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;

/**
 *
 * @author alexey
 */
public class PriceViewDialog extends javax.swing.JDialog {

    /** Creates new form PriceViewDialog */
    public PriceViewDialog(java.awt.Frame parent, boolean modal) {
        super(parent, modal);
        initComponents();
        initHTML();
        setVisible(true);
    }

    private void initHTML() {
        HTMLEditorKit editorkit = new HTMLEditorKit();
        HTMLDocument doc = (HTMLDocument) editorkit.createDefaultDocument();
        jEditorPane1.setDocument(doc);
        jEditorPane1.setEditorKit(editorkit);
        jEditorPane1.setText(getHTML());
        //jEditorPane1.setp
        //jEditorPane1.setText(getHTML());
    }

    private String getHTML() {
        String str = "<html>"+
                "<head></head>"+
        "<body>"+
                //"<img src=\"file:///Users/alexey/work/PriceMaker/pict.jpg\" ></img>"+

                "<table border=1>"+
                "<tr>" +
                "<td background=\"file:///Users/alexey/work/PriceMaker/pict.jpg\" width=\"252\" height=\"184\">"+
                    "<table border=1>" +
"<tr height=\"9\">"+
"<td></td>"+
"<td></td>"+
"<td></td>"+
"</tr>"+

"<tr>"+
"<td></td>"+
"<td height=\"1\" align=\"right\"><font size=\"1\">Организация</font></td>"+
"<td width=\"15\"></td>"+
"</tr>"+

"<tr>"+
"<td></td>"+
"<td align=\"right\" height=\"1\"><font size=\"3\">ООО ОСТРОВОК</font></td>"+
"<td></td>"+
"</tr>"+

"<tr>"+
"<td height=\"1\" colspan=\"3\"></td>"+
"</tr>"+

"<tr>"+
"<td colspan=\"3\" align=\"center\" height=\"5\">Наименование товара</td>"+
"</tr>"+

"<tr>"+
"<td colspan=\"3\" align=\"center\" height=\"5\"><font face=\"Times New Roman, Arial</td>\" size=\"5\"><b>Название</b></font></td>"+
"</tr>"+

"<tr>"+
"<td colspan=\"3\" align=\"center\" height=\"5\">Доп информация</td>"+
"</tr>"+

"<tr height=\"1\">"+
"<td align=\"center\"><font size=\"1\">Поставщик</font></td>"+
"<td colspan=\"2\" align=\"right\"><font size=\"1\">Цена за</font><div style=\"width:100px;\"></div></td>"+
"</tr>"+

"<tr>"+
"<td colspan=\"3\" align=\"center\">text</td>"+
"</tr>"+
                    
                    "</table>" +
                "</td>"+
                "</tr>"+

                "</table>"+

/*
        "<table background=\"file:///Users/alexey/work/PriceMaker/pict.jpg\" width=\"252\" height=\"186\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" >"+
"<tr height=\"9\">"+
"<td></td>"+
"<td></td>"+
"<td></td>"+
"</tr>"+

"<tr>"+
"<td></td>"+
"<td height=\"1\" align=\"right\"><font size=\"1\">Организация</font></td>"+
"<td width=\"15\"></td>"+
"</tr>"+

"<tr>"+
"<td></td>"+
"<td align=\"right\" height=\"1\"><font size=\"3\">ООО ОСТРОВОК</font></td>"+
"<td></td>"+
"</tr>"+

"<tr>"+
"<td height=\"1\" colspan=\"3\"></td>"+
"</tr>"+

"<tr>"+
"<td colspan=\"3\" align=\"center\" height=\"5\">Наименование товара</td>"+
"</tr>"+

"<tr>"+
"<td colspan=\"3\" align=\"center\" height=\"5\"><font face=\"Times New Roman, Arial</td>\" size=\"5\"><b>Название</b></font></td>"+
"</tr>"+

"<tr>"+
"<td colspan=\"3\" align=\"center\" height=\"5\">Доп информация</td>"+
"</tr>"+

"<tr height=\"1\">"+
"<td align=\"center\"><font size=\"1\">Поставщик</font></td>"+
"<td colspan=\"2\" align=\"right\"><font size=\"1\">Цена за</font><div style=\"width:100px;\"></div></td>"+
"</tr>"+

"<tr>"+
"<td colspan=\"3\" align=\"center\">text</td>"+
"</tr>"+

"</table> "+

"<!--"+
"<div style=\"background: url(/Users/alexey/Desktop/pict.bmp) no-repeat top left;\">"+
"Здесь_какой-нибудь_текст_поверх_картинки."+
"</div>"+
"-->"+
 * */
                "</body>"+
" </html>";
        return str;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jEditorPane1 = new javax.swing.JEditorPane();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
        setName("Form"); // NOI18N

        jPanel1.setName("jPanel1"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(org.plotnikov.pricemaker.PriceMakerApp.class).getContext().getResourceMap(PriceViewDialog.class);
        jEditorPane1.setContentType(resourceMap.getString("jEditorPane1.contentType")); // NOI18N
        jEditorPane1.setEditable(false);
        jEditorPane1.setName("jEditorPane1"); // NOI18N
        jScrollPane1.setViewportView(jEditorPane1);

        org.jdesktop.layout.GroupLayout jPanel1Layout = new org.jdesktop.layout.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1Layout.createSequentialGroup()
                .add(jScrollPane1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 225, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(75, Short.MAX_VALUE))
        );

        org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
            .add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                PriceViewDialog dialog = new PriceViewDialog(new javax.swing.JFrame(), true);
                dialog.addWindowListener(new java.awt.event.WindowAdapter() {

                    public void windowClosing(java.awt.event.WindowEvent e) {
                        System.exit(0);
                    }
                });
                dialog.setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JEditorPane jEditorPane1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
}
